package cn.zwk.mapping;

import cn.zwk.config.EsConfig;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class ProductMapping {
    @PostConstruct
    public void init() {
        EsConfig.addMapping(INDEX_NAME, MAPPING_TEMPLATE);
    }

    public static final String INDEX_NAME = "product";
    public static final String MAPPING_TEMPLATE = "" +
            "{\n" +
            "  \"mappings\": {\n" +
            "    \"properties\": {\n" +
            "      \"skuId\": {\n" +
            "        \"type\": \"long\"\n" +
            "      },\n" +
            "      \"spuId\": {\n" +
            "        \"type\": \"keyword\"\n" +
            "      },\n" +
            "      \"skuTitle\": {\n" +
            "        \"type\": \"text\",\n" +
            "        \"analyzer\": \"ik_smart\"\n" +
            "      },\n" +
            "      \"skuPrice\": {\n" +
            "        \"type\": \"keyword\"\n" +
            "      },\n" +
            "      \"skuImg\": {\n" +
            "        \"type\": \"keyword\",\n" +
            "        \"index\": false,\n" +
            "        \"doc_values\": false\n" +
            "      },\n" +
            "      \"saleCount\": {\n" +
            "        \"type\": \"long\"\n" +
            "      },\n" +
            "      \"hasStock\": {\n" +
            "        \"type\": \"boolean\"\n" +
            "      },\n" +
            "      \"hotScore\": {\n" +
            "        \"type\": \"long\"\n" +
            "      },\n" +
            "      \"brandId\": {\n" +
            "        \"type\": \"long\"\n" +
            "      },\n" +
            "      \"catalogId\": {\n" +
            "        \"type\": \"long\"\n" +
            "      },\n" +
            "      \"brandName\": {\n" +
            "        \"type\": \"keyword\",\n" +
            "        \"index\": false,\n" +
            "        \"doc_values\": false\n" +
            "      },\n" +
            "      \"brandImg\": {\n" +
            "        \"type\": \"keyword\",\n" +
            "        \"index\": false,\n" +
            "        \"doc_values\": false\n" +
            "      },\n" +
            "      \"catalogName\": {\n" +
            "        \"type\": \"keyword\",\n" +
            "        \"index\": false,\n" +
            "        \"doc_values\": false\n" +
            "      },\n" +
            "      \"attrs\": {\n" +
            "        \"type\": \"nested\",\n" +
            "        \"properties\": {\n" +
            "          \"attrId\": {\n" +
            "            \"type\": \"long\"\n" +
            "          },\n" +
            "          \"attrName\": {\n" +
            "            \"type\": \"keyword\",\n" +
            "            \"index\": false,\n" +
            "            \"doc_values\": false\n" +
            "          },\n" +
            "          \"attrValue\": {\n" +
            "            \"type\": \"keyword\"\n" +
            "          }\n" +
            "        }\n" +
            "      }\n" +
            "    }\n" +
            "  }\n" +
            "}";
}
